package common

import (
	"strings"
)

// IsContain - 判断字符串是否包含子串 24,25,26,15,11 是否包含25
func IsContain(str, target string) bool {
	return str == target || strings.HasPrefix(str, target+",") || strings.HasSuffix(str, ","+target) || strings.Contains(str, ","+target+",")
}

// DeleteStr - 从字符串中删除子串 24,25,26,15,11 ；删除25 ；返回24,26,15,11
func DeleteStr(str, target string) string {
	if str == target {
		return str[len(target):]
	}
	if strings.HasPrefix(str, target+",") {
		return str[len(target)+1:]
	}
	if strings.HasSuffix(str, ","+target) {
		return str[:len(str)-len(target)-1]
	}
	if strings.Contains(str, ","+target+",") {
		return strings.Replace(str, ","+target+",", ",", -1)
	}

	return str
}
